<?
include('../scaffold/content.php');
include('../controller/handler.php');
include('../controller/philomousia.php');

include('../module/var.inc.php');

session_start();

$hd = new Handler();
$hd->openDB();
$base_url = $hd->getBaseURL();
if($hd->getPassword()==sha1($_SESSION['password'])) {
	$ph = new Philomousia();
	if(isset($_GET['id'])) {
		$content = $ph->loadContentFromCommentId($_GET['id'], $hd);
		$result = $ph->deleteComment($_GET['id'], $hd);
		if($content!=NULL && $result) {
			$feedback = "Commento eliminato con successo. Torna all'articolo <a href=\"".
				$base_url.$links[$content->getType()]."/post:".$content->getId()."\"><span class=\"highline\">".
				$content->getTitle()."</span></a>";
		} else {
			$feedback = "Errore durante l'eliminazione del commento. Consultare il log di sistema per maggiori dettagli.";
		}
	}
}

$hd->closeDB();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
	<? include('../module/head.inc.php'); ?>
	<meta name="robots" content="noindex, nofollow"/>
</head>

<body>
<div id="content">
<?include('../module/header.inc.php');?>

<?if($hd->getPassword()==sha1($_SESSION['password'])) {?>

<div class="form">
	<div class="upper_bar_main"><div class="upper_bar_round"></div></div>
	<div class="body_main_left">
	<div class="body_main_right">
	<div class="body_main">
	<?if($feedback) {?><p id="feedback" class="highline"><?echo $feedback;?></p> <?}?>
	
	<p class="small admin_action"><a href="<?echo $base_url;?>panel">&larr; Pannello di amministrazione</a></p>
	</div></div></div>
	<div class="lower_bar_main"><div class="lower_bar_round"></div></div>
</div>

<?}?>

<? include('../module/footer.inc.php'); ?>
</div>
</body>
</html>
